<?php 

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  $insertSQL = sprintf("UPDATE textplug SET judul=%s, konten=%s, stjudul=%s WHERE id=%s ",
                       GetSQLValueString($_POST['judul'], "text"),
                       GetSQLValueString($_POST['konten'], "text"),
                       GetSQLValueString($_POST['stjudul'], "int"),
                       GetSQLValueString($_POST['id'], "int"));

  mysql_select_db($database_konek, $konek);
  $Result1 = mysql_query($insertSQL, $konek) or die(mysql_error());

 ?>
	
	 <script language="javascript">
  	<!--
     	    alert('Edit Success')
			window.location = "home.php?page=pluginview&p=<?php echo $_GET['p'] ?>&root=add_module.php";
			
   	--></script>
	<?php
}

mysql_select_db($database_konek, $konek);
$query_plugtext = "SELECT * FROM textplug WHERE id = $_GET[id] ";
$plugtext = mysql_query($query_plugtext, $konek) or die(mysql_error());
$row_plugtext = mysql_fetch_assoc($plugtext);
$totalRows_plugtext = mysql_num_rows($plugtext);
?>

  <form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
    <table width="100%" align="center">
      <tr valign="baseline">
        <td width="12%" align="left" valign="top" nowrap="nowrap"><strong>Judul:</strong></td>
        <td width="88%"><input type="text" name="judul" class="form-control" value="<?php echo $row_plugtext['judul']; ?>" size="32" /></td>
      </tr>
      <tr valign="baseline">
        <td align="left" valign="top" nowrap="nowrap"><strong>Tamplkan judul:</strong></td>
        <td><select name="stjudul" class="form-control">
          <option value="1" <?php if ($row_plugtext['stjudul']==1) {echo "SELECTED";} ?>>ya</option>
          <option value="0" <?php if ($row_plugtext['stjudul']==0) {echo "SELECTED";} ?>>tidak</option>
        </select></td>
      </tr>
      <tr valign="baseline">
        <td align="left" valign="top" nowrap="nowrap"><strong>Konten:</strong></td>
        <td><textarea name="konten" cols="32" rows="6" class="form-control textarea-editor" ><?php echo $row_plugtext['konten']; ?></textarea></td>
      </tr>
      <tr valign="baseline">
        <td align="left" valign="top" nowrap="nowrap">&nbsp;</td>
        <td><input type="submit" value="Submit" id="status-update-btn" class="btn btn-primary pull-right" /></td>
      </tr>
    </table>
    <input type="hidden" name="id" value="<?php echo $row_plugtext['id']; ?>" />
    <input type="hidden" name="MM_insert" value="form1" />
</form>

<?php

mysql_free_result($plugtext);
?>
